package io.renren.modules.busi.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import io.renren.common.validator.ValidatorUtils;
import io.renren.modules.busi.dao.B63VehicleTypeDao;
import io.renren.modules.busi.entity.B63RoadTypeEntity;
import io.renren.modules.sys.controller.AbstractController;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.busi.entity.B63VehicleTypeEntity;
import io.renren.modules.busi.service.B63VehicleTypeService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 车辆类型
 *
 * @author Liu Yunchang
 * @email yunchang75@aliyun.com
 * @date 2020-08-18 08:20:19
 */
@RestController
@RequestMapping("busi/b63vehicletype")
public class B63VehicleTypeController  extends AbstractController{
    @Autowired
    private B63VehicleTypeService b63VehicleTypeService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("busi:b63vehicletype:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = b63VehicleTypeService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 车辆类型列表
     */
    @RequestMapping("/select")

    public R select(){
        List<B63VehicleTypeEntity> list = b63VehicleTypeService.list();

        return R.ok().put("list", list);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{typeId}")
    @RequiresPermissions("busi:b63vehicletype:info")
    public R info(@PathVariable("typeId") Integer typeId){
        B63VehicleTypeEntity b63VehicleType = b63VehicleTypeService.getById(typeId);

        return R.ok().put("b63VehicleType", b63VehicleType);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("busi:b63vehicletype:save")
    public R save(@RequestBody B63VehicleTypeEntity b63VehicleType){
        b63VehicleTypeService.save(b63VehicleType);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("busi:b63vehicletype:update")
    public R update(@RequestBody B63VehicleTypeEntity b63VehicleType){
        ValidatorUtils.validateEntity(b63VehicleType);
        b63VehicleTypeService.updateById(b63VehicleType);
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("busi:b63vehicletype:delete")
    public R delete(@RequestBody Integer[] typeIds){
        b63VehicleTypeService.removeByIds(Arrays.asList(typeIds));

        return R.ok();
    }

}
